package l3.info.Projet.Client;


import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import l3.info.Projet.RMI.RequettesReseau;

/**
 * This is a simple print client.
 * 
 * @author Aboulkacem Hamid
 */
public class RequettesClient {
	private static RequettesReseau connexionServer = null;

	public RequettesClient() {
		if (connexionServer == null) {
			System.setSecurityManager(new RMISecurityManager());
			try {
				Registry registry = LocateRegistry.getRegistry("localhost");
				connexionServer = (RequettesReseau) registry.lookup("serveur");
			} catch (Exception e) {
				// Something wrong here
				e.printStackTrace();
			}
		}
	}
	
	public RequettesReseau getReseau() {
		return connexionServer; 
	}
	
	public void envoyerUtilisateur(Utilisateur u) {
				try {
					getReseau().printUtilisateur(u);
				} catch (RemoteException e) {
					// TODO Auto-generated catch block
					System.err.println("Echec d'envoi \n"+ e.getMessage());
				}
		}
}